// eslint-disable-next-line
import {UserLayout, BasicLayout, BlankLayout} from '@/layouts'

const RouteView = {
  name: 'RouteView',
  render: h => h('router-view')
}

export const asyncRouterMap = [
  {
    path: '/',
    name: 'index',
    component: BasicLayout,
    meta: {title: '首页'},
    redirect: '/dashboard',
    children: [
      // 控制面板
      {
        path: '/dashboard',
        name: 'dashboard',
        component: RouteView,
        redirect: '/dashboard/personal',
        meta: {title: '信息概览', icon: 'bar-chart', permission: ['dashboard']},
        children: [
          {
            path: '/dashboard/personal',
            name: 'personal',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            component: () => import('@/views/dashboard/Personal'),
            meta: {title: '个人中心', icon: 'idcard', keepAlive: true, permission: ['dashboard-Personal']}
          },
          {
            path: '/dashboard/analysis',
            name: 'analysis',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            component: () => import('@/views/dashboard/Analysis'),
            meta: {title: '平台统计', icon: 'area-chart', keepAlive: true, permission: ['dashboard-Analysis']}
          },
        ]
      },

      // 系统信息
      // {
      //   path: '/system',
      //   name: 'system',
      //   component: RouteView,
      //   redirect: '/system/station',
      //   meta: { title: '系统信息', icon: 'setting', permission: ['system'] },
      //   children: [
      //     {
      //       path: '/system/role',
      //       name: 'role',
      //       hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
      //       component: () => import('@/views/system/RoleList'),
      //       meta: { title: '角色管理', icon: 'safety', keepAlive: true, permission: ['system-Role'] }
      //     },
      //   ]
      // },

      // 基础信息
      {
        path: '/basic',
        name: 'basic',
        component: RouteView,
        redirect: '/basic/user',
        meta: {title: '基础信息', icon: 'appstore', permission: ['basic']},
        children: [
          {
            path: '/basic/user',
            name: 'basicUser',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            component: () => import('@/views/basic/UserList'),
            meta: {title: '人员管理', icon: 'team', keepAlive: true, permission: ['basic-User']}
          },
          {
            path: '/basic/station',
            name: 'basicStation',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            component: () => import('@/views/basic/StationList'),
            meta: {title: '站点管理', icon: 'home', keepAlive: true, permission: ['basic-Station']}
          },
          {
            path: '/basic/listBike',
            name: 'stationBikeList',
            hidden: true,
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            component: () => import('@/views/basic/StationBikeList'),
            meta: {title: '站点车辆', icon: 'car', keepAlive: true, permission: ['basic-ListBike']}
          },
          {
            path: '/basic/bike',
            name: 'basicBike',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            component: () => import('@/views/basic/BikeList'),
            meta: {title: '车辆管理', icon: 'car', keepAlive: true, permission: ['basic-Bike']}
          },
          {
            path: '/basic/bikeRecord',
            name: 'bikeRecord',
            hidden: true,
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            component: () => import('@/views/basic/BikeRecord'),
            meta: {title: '车辆管理', icon: 'car', keepAlive: true, permission: ['basic-BikeRecord']}
          },
        ]
      },

      // 车辆租借
      {
        path: '/bike',
        name: 'bike',
        component: RouteView,
        redirect: '/bike/user',
        meta: {title: '租借功能', icon: 'pay-circle', permission: ['bike']},
        children: [
          {
            path: '/bike/card',
            name: 'bikeCard',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            component: () => import('@/views/bike/CardList'),
            meta: {title: '租借卡', icon: 'credit-card', keepAlive: true, permission: ['bike-Card']}
          },
          {
            path: '/bike/ride',
            name: 'ride',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            component: () => import('@/views/bike/RideList'),
            meta: {title: '车辆租借', icon: 'transaction', keepAlive: true, permission: ['bike-Ride']}
          },
        ]
      },
    ]
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login')
      },
      {
        path: 'register',
        name: 'register',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register')
      },
      {
        path: 'register-result',
        name: 'registerResult',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult')
      },
      {
        path: 'recover',
        name: 'recover',
        component: undefined
      }
    ]
  },

  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
  }
]
